<?php
define('DISABLEDEFENSE', true);
define('DISABLEXSSCHECK', true);

require '../../../../class/class_core.php';
C::app()->init();
require_once "hupijiao_api.php";

global $_G;

define('BOAN_PAYMENT_NAME', 'plugin/boan_payment');


if(empty($_G['cache']['plugin'])){
    loadcache('plugin');
}
$data = $_GET;

$vars = $_G['cache']['plugin']['boan_payment'];
$appid     = $data['attach'] == 'wxpay' ? $vars['hpjpay_appid'] : $vars['hpjpay_alipay_appid'];
$appsecret = $data['attach'] == 'wxpay' ? $vars['hpjpay_appsecret'] : $vars['hpjpay_alipay_appsecret'];
$plugin_id = 'boan_payment';
$gateway   = $vars['hpjpay_gateway'];


foreach ($data as $k=>$v){
    $data[$k] = stripslashes($v);
}

if(!isset($data['hash']) || !isset($data['trade_order_id'])){
    echo 'failed';
    exit;
}

if(isset($data['plugins']) && $data['plugins'] != $plugin_id){
    echo 'failed';
    exit;
}

$appkey =$appsecret;
$hash =XH_Payment_Api::generate_xh_hash($data,$appkey);

if($data['hash'] != $hash){
    echo 'failed';
    exit;
}

echo 'success';
exit;



